Skip to content

fix(tracing): Skip child span creation in streaming path when no current span (web frameworks)#6810

Merged
ericapisani merged 5 commits into
masterfrom
ivana/streaming-child-spans-web-frameworks
Jul 15, 2026
Merged

fix(tracing): Skip child span creation in streaming path when no current span (web frameworks)#6810
ericapisani merged 5 commits into
masterfrom
ivana/streaming-child-spans-web-frameworks

Conversation

@sentrivana

Copy link
Copy Markdown
Contributor

Summary

  • When span streaming is enabled and there is no current span, web framework integrations should not create new root segments for child-span operations
  • Adds a sentry_sdk.traces.get_current_span() is None guard before creating spans in the streaming path
  • Affected integrations: starlette, starlite, litestar, graphene, strawberry, aiohttp

Test plan

  • Existing tests pass
  • Verify that in streaming mode, no orphan root segments are created for web framework sub-operations when there's no active span

🤖 Generated with Claude Code

…ent span (web frameworks)

When span streaming is enabled and there is no current span,
web framework integrations should not create new root segments
for child-span operations. This adds a guard check using
`sentry_sdk.traces.get_current_span()` before creating spans
in the streaming path.

Affected integrations: starlette, starlite, litestar, graphene,
strawberry, aiohttp.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread sentry_sdk/integrations/aiohttp.py Outdated
…uards

The outgoing http.client span from the test fixture is now suppressed
when there is no active span, reducing span counts in tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ericapisani ericapisani marked this pull request as ready for review July 14, 2026 19:43
@ericapisani ericapisani requested a review from a team as a code owner July 14, 2026 19:43
Comment thread tests/integrations/aiohttp/test_aiohttp.py
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

91785 passed | ⏭️ 6302 skipped | Total: 98087 | Pass Rate: 93.58% | Execution Time: 314m 44s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 62.16%. Project has 2456 uncovered lines.
❌ Project coverage is 89.75%. Comparing base (base) to head (head).

Files with missing lines (5)
File Patch % Lines
sentry_sdk/integrations/strawberry.py 38.46% ⚠️ 8 Missing and 5 partials
sentry_sdk/integrations/litestar.py 50.00% ⚠️ 3 Missing and 3 partials
sentry_sdk/integrations/aiohttp.py 90.91% ⚠️ 1 Missing and 2 partials
sentry_sdk/integrations/starlette.py 50.00% ⚠️ 1 Missing and 1 partials
sentry_sdk/integrations/starlite.py 50.00% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    89.79%    89.75%    -0.04%
==========================================
  Files          193       193         —
  Lines        23929     23957       +28
  Branches      8286      8310       +24
==========================================
+ Hits         21485     21501       +16
- Misses        2444      2456       +12
- Partials      1361      1370        +9

Generated by Codecov Action

…om:getsentry/sentry-python into ivana/streaming-child-spans-web-frameworks
@ericapisani ericapisani merged commit dbf5d03 into master Jul 15, 2026
271 of 273 checks passed
@ericapisani ericapisani deleted the ivana/streaming-child-spans-web-frameworks branch July 15, 2026 15:05
ericapisani added a commit that referenced this pull request Jul 15, 2026
The streaming path no longer emits a client span when there is no current
span (#6810), so unpack only the server span.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants